#!/usr/bin/python
# -*- coding: utf-8 -*-
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: unicode.py
# Description: 
# 
# Edit History: 
#   2011-08-13    File created.
#===============================================================================

#\u0020表示十六位元0x0020所代表的Unicode字元 
print u'Hello\u0020World !'
print u'你好'
print '你好'
#u'Hello World !'

#如果你要使用一個特別的編碼系統，但是要印出對應的Unicode碼時，你可以使用 unicode() 函式，加上這個編碼系統的名稱當作第二個參數。
print unicode('您好', 'UTF-8')  # 你好
print unicode('\xe4\xbd\xa0\xe5\xa5\xbd', 'UTF-8')  # 你好
#print int("你好")  # 顯示其unicode的16進位編碼

#如果要把Unicode字串轉換為一般的字串編碼時，可以使用Unicode物件的 encode() 方法(method)。 
print u"äöü".encode('UTF-8')
#'\303\244\303\266\303\274'

